package Lab;

import java.util.*;

/**
 * description:
 * author:zcx
 * lenovo
 * 时间：2022.01.29.17.01
 */
public class IntSortDemo {
    public static void main(String[] args) {
        Integer[] is={1,23,124,5,67,3,35,864,2,4};
        System.out.println(Arrays.toString(is));
        //升序
        Arrays.sort(is,(a,b)->a-b);
        Arrays.sort(is, Comparator.comparingInt(a->a));
        System.out.println(Arrays.toString(is));

        //降序
        Arrays.sort(is,(a,b)->b-a);
        System.out.println(Arrays.toString(is));
        //乱序
        Random rs=new Random();
        Arrays.sort(is,(a,b)->rs.nextBoolean()?-1:1);
        //转换为List,shuff
        var list=new ArrayList(Arrays.stream(is).toList());
        Collections.shuffle(list);
        list.toArray(is);
        System.out.println(Arrays.toString(is));


    }
}
